<?php
/**
 * Created by JetBrains PhpStorm.
 * User: T420
 * Date: 11/12/12
 * Time: 10:07 AM
 * To change this template use File | Settings | File Templates.
 */
class Models_News extends Libs_Model
{
    public function __construct()
    {
        parent::__construct();
    }
    public function getnews($stt)
    {
        $this->db->connect();
        $str="select * from lb_news";
        if($stt!='')
            $str.=" where status='$stt'";
        $list=$this->db->executeQuery($str);
        $this->db->disconnect();
        return $list;
    }
    public function getnewdetail($id)
    {
        $this->db->connect();
        $list=$this->db->executeQuery("select * from lb_news where newsid='$id'");
        $this->db->disconnect();
        return $list;
    }
    public function updatenews($id,$tieude,$tomtat,$anh,$trangthaitin,$noidung)
    {
        $this->db->connect();
        $this->db->query("update lb_news set title='$tieude', brief='$tomtat',image='$anh',status='$trangthaitin',content='$noidung'  where newsid='$id'");
        $this->db->disconnect();

    }
    public function insertnews($tieude,$tomtat,$anh,$trangthaitin,$noidung)
    {
        $this->db->connect();
        $this->db->query("insert lb_news(title,brief,image,status,content,postdate) values ('$tieude','$tomtat','$anh','$trangthaitin','$noidung',now())");
        $this->db->disconnect();

    }
    public function delnews($id)// xoa san pham
    {
        $this->db->connect();
        $this->db->query("delete from lb_news where newsid in ('$id')");
        $this->db->disconnect();
    }

}
